package plp.functional2.expression;

import static plp.expressions1.util.ToStringProvider.listToString;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import plp.expressions1.util.Tipo;
import plp.expressions2.expression.Id;
import plp.expressions2.expression.Valor;
import plp.expressions2.memory.AmbienteCompilacao;
import plp.expressions2.memory.AmbienteExecucao;
import plp.expressions2.memory.VariavelJaDeclaradaException;
import plp.expressions2.memory.VariavelNaoDeclaradaException;
import plp.functional2.declaration.DefProcesso;
import plp.functional2.primitive.Primitiva;
import plp.functional2.util.PartialInstantiatorVisitorFuncao;


public class ValorProcesso extends DefProcesso implements ValorAbstrato{

	public ValorProcesso(List<Id> argsId, Primitiva exp) {
		super(argsId, exp);
	}
	
	public Valor avaliar(AmbienteExecucao ambiente) {System.out.println("### ValorFuncao que chama o Visitor ###");
		Set<Id> variaveisLocais = Collections.unmodifiableSet(new HashSet<Id>(this.getListaId()));
		return (Valor) PartialInstantiatorVisitorFuncao.getInstance().visit(this,	ambiente, variaveisLocais);
	}

	@Override
	public String toString() {
		return String.format("proc %s . %s", listToString(getListaId(), " "), getPrimitiva());
	}

	public Tipo getTipo(AmbienteCompilacao amb)
			throws VariavelNaoDeclaradaException, VariavelJaDeclaradaException {
		// TODO Auto-generated method stub
		return null;
	}
}